package com.ygxsk.carhome.ui.signature;

import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.afollestad.materialdialogs.MaterialDialog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.arialyy.annotations.Download;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.aria.util.ALog;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.ClickUtils;
import com.blankj.utilcode.util.ColorUtils;
import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.KeyboardUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.PathUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.flyco.roundview.RoundTextView;
import com.gyf.immersionbar.ImmersionBar;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;
import com.hjq.toast.Toaster;
import com.kathline.library.content.ZFileConfiguration;
import com.kathline.library.content.ZFileContent;
import com.kongzue.dialogx.dialogs.PopTip;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.util.SmartGlideImageLoader;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.yanzhenjie.permission.AndPermission;
import com.yanzhenjie.permission.runtime.Permission;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.alertview.AlertView;
import com.ygxsk.carhome.alertview.OnItemClickListener;
import com.ygxsk.carhome.constant.ConstantApi;
import com.ygxsk.carhome.constant.ConstantSign;
import com.ygxsk.carhome.constant.ExtraKey;
import com.ygxsk.carhome.constant.ExtraValue;
import com.ygxsk.carhome.enumwrap.SignatureVehicleType;
import com.ygxsk.carhome.event.EventSignatureDetail;
import com.ygxsk.carhome.event.EventSignatureMain;
import com.ygxsk.carhome.listener.AuthorityCallbackListener;
import com.ygxsk.carhome.listener.DoSomeThingListener;
import com.ygxsk.carhome.listener.ErrorParentExtraSingle;
import com.ygxsk.carhome.listener.RxBus;
import com.ygxsk.carhome.permission.PermissionSetting;
import com.ygxsk.carhome.permission.RuntimeRationale;
import com.ygxsk.carhome.response.EvaluateWadeInfo;
import com.ygxsk.carhome.response.FileSignatureManage;
import com.ygxsk.carhome.response.FileTemplatePage;
import com.ygxsk.carhome.response.SignatureLaunchSign;
import com.ygxsk.carhome.retrofit.AddLogUpLoadInfo;
import com.ygxsk.carhome.retrofit.ApiException;
import com.ygxsk.carhome.retrofit.ApiRequestSubListener;
import com.ygxsk.carhome.retrofit.ApiService;
import com.ygxsk.carhome.retrofit.ErrorConsumer;
import com.ygxsk.carhome.retrofit.NetworkManager;
import com.ygxsk.carhome.retrofit.ResponseTransformer;
import com.ygxsk.carhome.rxbus.RxBusCalendarTimeForSignatureAdd;
import com.ygxsk.carhome.rxbus.RxBusCarWade;
import com.ygxsk.carhome.rxbus.RxBusRunManGroupHeadOrTeamCheck;
import com.ygxsk.carhome.sys.PermissionNameConvert;
import com.ygxsk.carhome.ui.ErrorActivity;
import com.ygxsk.carhome.ui.evaluate.CalendarViewCustomPopup;
import com.ygxsk.carhome.ui.evaluate.EvaluateWadePopu;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.carhome.utils.DateUtilFir;
import com.ygxsk.carhome.utils.TimeUtilSer;
import com.ygxsk.carhome.views.ClearEditText;
import com.ygxsk.integrated.retrofit.Parameterkey;

import org.greenrobot.eventbus.EventBus;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-10-25  11:52
 * @Description:发起签约之后 ，跳到的 选择合同模板的 表单提交页面；
 */
public class SignatureAddSubmitToActivity extends ErrorActivity implements ErrorParentExtraSingle {

    //选择签约时间
    @BindView(R.id.textviewagreentimesignature)
    TextView textViewAgreenTimeSignature;

    //选择签约时间
    @BindView(R.id.textviewleadformanagerperson)
    TextView textViewLeadForManagerPerson;

    //选择签约时间
    @BindView(R.id.textviewsigntemplate)
    TextView textViewSignTemplate;

    //填写合同的金额--暂时不填写
//    @BindView(R.id.editviewinputamountsignature)
//    ClearEditTextTouch editViewInputAmountSignature;

    //车辆类型
    @BindView(R.id.radiogroupvehicletype)
    RadioGroup radioGroupVehicleType;

    //左侧的新车按钮
    @BindView(R.id.radiobuttonvehicletypecarnew)
    RadioButton radioButtonVehicleTypeCarNew;

    //右侧的二手车按钮
    @BindView(R.id.radiobuttonvehicletypecarold)
    RadioButton radioButtonVehicleTypeCarOld;

    //选中经理人的id信息内容
    private String managerId_upLoad;

    //合同档案的id信息
    private String informationId_upLoad = "";
    //合同模板的id信息，做上传的
    private String signTemplateId_upLoad;

    //目前当前的日期，用来和后边选中时间做比对
    private String appointDate_current = "";
    //上传用时间 日期
    private String appointDate_upLoad = "";

    //是新车还是二手车的选择  //车辆类型  1新车  2二手车
    private String vehicleType_upLoad = "";

    //获取客户认证二维码的时候 填充的客户手机号
    private String clientPhone_upLoad = "";

    //合同的类别  新车  二手车 ？
    private String archiveTypeId_upLoad;

    //客户类型   客户类型(0:个人;1:企业),默认是个人,默认是个人
    private String clientType_upLoad = "0";

    //弹窗关于签约时间的
    private BasePopupView basePopupViewAgreenmentTime;

    //添加合同模板的页面；
    private BasePopupView basePopupView_signTemplateName;

    //携带这条数据的内容；
//    private FileSignatureAgreement extra_signature_fileSignatureAgreement;
    //携带主要是合同类型，比对 档案的类型用到
    private FileSignatureManage extra_signature_fileSignatureManage;

    //在线获取合同模板的列表，功勾选用
//    private ArrayList<FileTemplatePage> mDataResources_signTemplateName = new ArrayList<>();
    //是携带弹窗的转换值内容
    private ArrayList<EvaluateWadeInfo> mDataResources_evaluateWadeInfo = new ArrayList<>();

    //该下载apk任务的任务id值内容；
    private long taskDownLoadApkId;


    @OnClick({R.id.layoutagreentimeoutsideadapter, //签约时间
            R.id.layoutleadformanager, //经理人
            R.id.layoutforsigntemplatename, //合同模板
            R.id.layoutbutton_file_submit_singature, //发起签约提交
    })
    public void onViewClickedInSignature(View v) {

        switch (v.getId()) {

            case R.id.layoutagreentimeoutsideadapter: {
                //签约时间

                //时间弹窗
                // TODO: 2023-09-21 15:26 时间弹窗
                KeyboardUtils.hideSoftInput(mActivityInstance);

                CalendarViewCustomPopup calendarViewCustomPopup = new CalendarViewCustomPopup(ExtraValue.MODIFY_SIGNATURE_AGREEMENT_TIME_SELECT,
                        1,
                        SignatureAddSubmitToActivity.this, false);

                basePopupViewAgreenmentTime = new XPopup.Builder(SignatureAddSubmitToActivity.this)
                        .hasShadowBg(true)
                        .moveUpToKeyboard(false) //如果不加这个，评论弹窗会移动到软键盘上面
                        .isViewMode(true)
                        .isDestroyOnDismiss(true) //对于只使用一次的弹窗，推荐设置这个
                        .isThreeDrag(false) //是否开启三阶拖拽，如果设置enableDrag(false)则无效
                        .asCustom(calendarViewCustomPopup)
                        .show();

                break;
            }

            case R.id.layoutleadformanager: {

                //经理人
                //跳转到分配人员列表
                Bundle extra_bundle = new Bundle();
                extra_bundle.putInt(ExtraKey.EXTRA_JUMPFROM_WHERE, ExtraValue.VALUE_JUMP_FORM_SIGNATURE_ADDSUBMIT_ACTIVITY);
//              extra_bundle.putParcelable(ExtraKey.EXTRA_LEAD_LIST_ITEM_BEAN, extra_lead_list_item_bean);
                ActivityUtils.startActivity(extra_bundle, SignatureManagerGroupActivity.class);

                break;
            }

            case R.id.layoutforsigntemplatename: {

                //合同模板
                KeyboardUtils.hideSoftInput(mActivityInstance);

                //这里每次都是新的才可以
//                ArrayList<EvaluateWadeInfo> mDataResources_evaluateWadeInfo = new ArrayList<>();

//                //重新过滤一遍值内容
//                if (mDataResources_signTemplateName != null && !mDataResources_signTemplateName.isEmpty()) {
//
//                    for (FileTemplatePage fileTemplatePageItem :
//                            mDataResources_signTemplateName) {
//
//                        EvaluateWadeInfo evaluateWadeInfo = new EvaluateWadeInfo();
//                        evaluateWadeInfo.setDictCode(fileTemplatePageItem.getSignTemplateId());//合同模板的id 模板ID
//                        evaluateWadeInfo.setDictLabel(fileTemplatePageItem.getSignTemplateName());//合同模板的名字
//
//                        if (mDataResources_evaluateWadeInfo != null) {
//                            mDataResources_evaluateWadeInfo.add(evaluateWadeInfo);
//                        }
//
//                    }
//                }

                EvaluateWadePopu evaluateWadePopu = new EvaluateWadePopu(SignatureAddSubmitToActivity.this,//
                        ExtraValue.MODIFY_EVALUATE_SIGNTEMPLATENAME_SELECT,//
                        mDataResources_evaluateWadeInfo);

                evaluateWadePopu.setTitleName(getResources().getString(R.string.plesechoosesigntemplate));

                //直接弹窗：
                basePopupView_signTemplateName = new XPopup.Builder(SignatureAddSubmitToActivity.this)//
                        .hasShadowBg(true)//
                        .isViewMode(true)//
                        .asCustom(evaluateWadePopu)//
                        .show();

                break;
            }

            case R.id.layoutbutton_file_submit_singature: {

                //2023-10-25 15:16 还有校验判断。
                //校验选择签约日期的
                if (TextUtils.isEmpty(appointDate_upLoad)) {
                    CommUtils.checkDialog(mAlertView);
                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.middletallstarttimeabnomalnull), true);
                    mAlertView.show();
                    return;
                }

                //选中经理人
                if (TextUtils.isEmpty(managerId_upLoad)) {
                    CommUtils.checkDialog(mAlertView);
                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.select_signature_person), true);
                    mAlertView.show();
                    return;
                }

                //选中合同模板
                if (TextUtils.isEmpty(signTemplateId_upLoad)) {
                    CommUtils.checkDialog(mAlertView);
                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.select_signature_signtemplate), true);
                    mAlertView.show();
                    return;
                }

                //是否选中 车辆类型
                if (TextUtils.isEmpty(vehicleType_upLoad)) {
                    CommUtils.checkDialog(mAlertView);
                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.select_signature_vehicletype), true);
                    mAlertView.show();
                    return;
                }

                //只有一个单个点击
                CommUtils.checkDialog(mAlertView);
                mAlertView = new AlertView(StringUtils.getString(R.string.clearaddorsubmitsuretitletips), //提示
                        StringUtils.getString(R.string.clearaddorsubmitsuremessage),//提示内容
                        StringUtils.getString(R.string.clearcachecancel), //取消
                        new String[]{StringUtils.getString(R.string.clearaddorsubmitsure)},//确定
                        null, mActivityInstance, AlertView.Style.Alert, new OnItemClickListener() {//
                    @Override
                    public void onItemClick(Object o, int position) {

                        if (position != AlertView.CANCELPOSITION) {

                            method_gainAddSubmitInfo_upLoad();

//                            if (flag_jumpfrom_where == ExtraValue.VALUE_JUMP_FORM_LEAD_ADD) {//【添加】
//
//                                method_gainAddSubmitInfo_upLoad();
//
//                            } else if (flag_jumpfrom_where == ExtraValue.VALUE_JUMP_FORM_LEAD_MODIFY) {//【修改】
//
//                                method_gainModifyInfo_upLoad();
//                            }

                        }
                    }
                });

                mAlertView.setCancelable(true);
                mAlertView.show();


                break;
            }

            default:
                break;
        }

    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mActivityInstance = this;

        processExtraData();

        //直接添加
        initViews();

        //获取经理人接口,然后获取合同模板接口。
        gainDatas();


    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_signature_add_submit2;
    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();

        ImmersionBar.with(this)//
                .titleBar(R.id.toolbarygxskout)
                .fitsSystemWindows(true)//解决状态栏和布局重叠问题，任选其一，默认为false，当为true时一定要指定statusBarColor()，不然状态栏为透明色，还有一些重载方法
                //.statusBarColor(R.color.colorPrimary)//
                //.navigationBarColor(R.color.colorPrimary)//
                //.keyboardEnable(true)
                .init();
    }

    @Override
    protected void initToolBar(ToolbarHelper toolbarHelper) {

        toolbarHelper.setTitle(getString(R.string.title_signature_create_addsubmit));
        toolbarHelper.setVersionName(true, AppUtils.getAppVersionName());
        toolbarHelper.setLayoutClose(false, "", null);
        toolbarHelper.setLayoutLeft(true, R.drawable.backicon, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //搜索客户信息，优先关闭软键盘
                KeyboardUtils.hideSoftInput(mActivityInstance);
                methodBack();
            }
        });

        //核销的历史记录顶部啥都没有；
        toolbarHelper.setLayoutRight(false, 0, "", null);
        //添加潜在客户的按钮
//        toolbarHelper.setLayoutRight(true, 1, getString(R.string.paint_booking_history), new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//                //2023-07-25 21:39 携带二维码的信息;
//                Bundle bundle = new Bundle();
////                bundle.putInt(ExtraKey.EXTRA_QRCODE_INFO, 0);
////                bundle.putInt(ExtraKey.BGAQRCODE_KEY, ExtraValue.BGAQRCODE_VALUE_FROM_CARD_DIST_HISTORY);
//                ActivityUtils.startActivity(bundle, PaintBookingSumHistoryActivity.class);
//
////                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "测试代码测试点击");
//            }
//        });

    }

    @Override
    protected void onClickNodata(View v) {

        //retain

    }

    @Override
    protected void initViews() {

        //先计算当前时间
        appointDate_current = TimeUtils.date2String(TimeUtils.getNowDate(), TimeUtilSer.simplemore);
        //默认是当前时间
        appointDate_upLoad = appointDate_current;

        //设置当前时间
        if (textViewAgreenTimeSignature != null) {
            textViewAgreenTimeSignature.setText(appointDate_current);
        }

        if (radioGroupVehicleType != null) {

            if (TextUtils.equals(vehicleType_upLoad, SignatureVehicleType.VEHICLETYPE_CAR_NEW.getIndex())) {

                //如果是新车标志
                radioButtonVehicleTypeCarNew.setChecked(true);
                radioButtonVehicleTypeCarOld.setChecked(false);

            } else if (TextUtils.equals(vehicleType_upLoad, SignatureVehicleType.VEHICLETYPE_CAR_OLD.getIndex())) {

                radioButtonVehicleTypeCarOld.setChecked(true);
                radioButtonVehicleTypeCarNew.setChecked(false);

            }

        }

        //选中新车或者二手车
        if (radioGroupVehicleType != null) {
            radioGroupVehicleType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(RadioGroup group, int checkedId) {

//                    public enum SignatureVehicleType {
//                        VEHICLETYPE_CAR_NEW("1"),
//                        VEHICLETYPE_CAR_OLD("2");

                    if (checkedId == R.id.radiobuttonvehicletypecarnew) {//新车

                        vehicleType_upLoad = SignatureVehicleType.VEHICLETYPE_CAR_NEW.getIndex();

                        if (radioButtonVehicleTypeCarNew != null) {
                            radioButtonVehicleTypeCarNew.setChecked(true);
                        }

                        if (radioButtonVehicleTypeCarOld != null) {
                            radioButtonVehicleTypeCarOld.setChecked(false);
                        }


                    } else if (checkedId == R.id.radiobuttonvehicletypecarold) {//二手车

                        vehicleType_upLoad = SignatureVehicleType.VEHICLETYPE_CAR_OLD.getIndex();

                        if (radioButtonVehicleTypeCarNew != null) {
                            radioButtonVehicleTypeCarNew.setChecked(false);
                        }

                        if (radioButtonVehicleTypeCarOld != null) {
                            radioButtonVehicleTypeCarOld.setChecked(true);
                        }

                    }

                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "选中的车辆类型-vehicleType_upLoad-->" + vehicleType_upLoad);

                }
            });

        }

        //监听选中的签约时间
        mCompositeDisposable.add(RxBus.getInstance()
                .toObserverable(RxBusCalendarTimeForSignatureAdd.class)//
                .subscribeOn(AndroidSchedulers.mainThread())//
                .observeOn(AndroidSchedulers.mainThread())//
                .subscribe(new Consumer<RxBusCalendarTimeForSignatureAdd>() {

                    @Override
                    public void accept(RxBusCalendarTimeForSignatureAdd rxBusCalendarTimeForSignatureAdd) throws Throwable {

                        if (rxBusCalendarTimeForSignatureAdd != null) {

                            if (rxBusCalendarTimeForSignatureAdd.getActionFlag() == ExtraValue.MODIFY_SIGNATURE_AGREEMENT_TIME_SELECT) {

                                //【筛选是签约时间】；
                                appointDate_upLoad = rxBusCalendarTimeForSignatureAdd.getManufactureDate();

                                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "选中的 预约时间 agreeMentTimeSelect-->" + appointDate_upLoad);

                                //判断空值
                                if (TextUtils.isEmpty(appointDate_upLoad)) {
                                    //选择时间异常，请重新选择；
                                    CommUtils.checkDialog(mAlertView);
                                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.middletallstarttimeabnomalnull), true);
                                    mAlertView.show();
                                    return;
                                }

                                //【开始时间】不能比【完成期限】更靠后:即是：如果【开始时间-大于完成时间，】那么弹窗提示，返回执行；
                                boolean compareTime = DateUtilFir.comparTwoTime(appointDate_current, appointDate_upLoad);

                                if (compareTime) {
                                    CommUtils.checkDialog(mAlertView);
                                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.signature_upload_time_completetime), true);
                                    mAlertView.show();
                                    return;
                                }

                                //判断适配器，从适配器之中取值textView赋值
                                if (textViewAgreenTimeSignature != null) {
                                    textViewAgreenTimeSignature.setText(rxBusCalendarTimeForSignatureAdd.getManufactureDate());
                                }


                            }
                        }
                    }
                }));


        //监听选中的经理人
        mCompositeDisposable.add(RxBus.getInstance().toObserverable(RxBusRunManGroupHeadOrTeamCheck.class)//
                .subscribeOn(AndroidSchedulers.mainThread())//
                .observeOn(AndroidSchedulers.mainThread())//
                .subscribe(new Consumer<RxBusRunManGroupHeadOrTeamCheck>() {//
                    @Override
                    public void accept(final RxBusRunManGroupHeadOrTeamCheck rxBusRunManGroupHeadOrTeamCheck) throws Exception {

                        if (rxBusRunManGroupHeadOrTeamCheck.getActionFlag() == ExtraValue.RXBUS_RUNMANGROUP_TEAMMAN) {

                            managerId_upLoad = rxBusRunManGroupHeadOrTeamCheck.getRunManGroupHeadOrTeamCheck().getCustomerId();
                            //LogUtils.d("itchen--收到了houseIdPass处理消息-->"+houseIdPass);

                            textViewLeadForManagerPerson.post(new Runnable() {
                                @Override
                                public void run() {
                                    textViewLeadForManagerPerson.setText(rxBusRunManGroupHeadOrTeamCheck.getRunManGroupHeadOrTeamCheck().getTrueName());
                                }
                            });
                        }

                    }
                }));

        //监听选中的合同模板
        mCompositeDisposable.add(RxBus.getInstance()//
                .toObserverable(RxBusCarWade.class)//
                .subscribeOn(AndroidSchedulers.mainThread())//
                .observeOn(AndroidSchedulers.mainThread())//
                .subscribe(new Consumer<RxBusCarWade>() {//
                    @Override
                    public void accept(RxBusCarWade rxBusCarWade) throws Exception {

                        int actionFlag = rxBusCarWade.getActionFlag();

                        EvaluateWadeInfo evaluateWadeInfo = rxBusCarWade.getEvaluateWadeInfo();

                        if (actionFlag == ExtraValue.MODIFY_EVALUATE_SIGNTEMPLATENAME_SELECT) {

                            if (evaluateWadeInfo != null) {

                                //车系的id信息；
                                signTemplateId_upLoad = evaluateWadeInfo.getDictCode();
//                                LogUtils.d("itchen---mCompositeDisposable---切换车辆品牌-车系-->" + carBrandSeriesLineSmallCategory);

                                if (textViewSignTemplate != null) {
                                    textViewSignTemplate.setText(evaluateWadeInfo.getDictLabel());
                                }
                            }
                        }
                    }
                }));
    }

    @Override
    protected void gainDatas() {

        //retain
        //第一步 获取经理人列表信息
//        gainDatas_sales_consultant();

        //获取签约模板
        gainDatas_sales_templatePage();


    }

    //获取合同签约模板
    private void gainDatas_sales_templatePage() {

        HashMap<String, Object> map = new HashMap<>();
        map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());
        // : 2023-10-24 17:49 这里传递的要是动态的
//        map.put(Parameterkey.informationId, mSession.getInformationId());

        if (extra_signature_fileSignatureManage != null) {
            map.put(Parameterkey.informationId, extra_signature_fileSignatureManage.getInformationId());
        }

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETTEMPLATEPAGE_URL);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.getTemplatePage_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .getTemplatePage(RequestBody.create(JSON.toJSONString(map,//
                                SerializerFeature.PrettyFormat, //
                                SerializerFeature.WriteMapNullValue), //
                        MediaType.parse(ApiService.HEADER_JSON)))//
                .compose(SignatureAddSubmitToActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<ArrayList<FileTemplatePage>>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                        if (!TextUtils.isEmpty(serverMessage)) {
                            ToastUtils.showShort(serverMessage);
                        }

                    }
                })).subscribe(new Consumer<ArrayList<FileTemplatePage>>() {
                    @Override
                    public void accept(ArrayList<FileTemplatePage> runManGroupHeadOrTeamCheckArrayList) throws Throwable {

                        //填充列表
//                        if (mDataResources_signTemplateName != null && !mDataResources_signTemplateName.isEmpty()) {
//                            mDataResources_signTemplateName.clear();
//                        }

//                        if (runManGroupHeadOrTeamCheckArrayList != null && !runManGroupHeadOrTeamCheckArrayList.isEmpty()) {
//                            if (mDataResources_signTemplateName != null) {
//                                mDataResources_signTemplateName.addAll(runManGroupHeadOrTeamCheckArrayList);
//                            }
//                        }

                        if (mDataResources_evaluateWadeInfo != null && !mDataResources_evaluateWadeInfo.isEmpty()) {
                            mDataResources_evaluateWadeInfo.clear();
                        }


                        if (runManGroupHeadOrTeamCheckArrayList != null && !runManGroupHeadOrTeamCheckArrayList.isEmpty()) {

                            //
                            //第一条合同模板默认--------------------------------------------------------------------------
                            FileTemplatePage fileTemplatePageItemFirstOne = runManGroupHeadOrTeamCheckArrayList.get(0);

                            if (fileTemplatePageItemFirstOne != null) {
                                signTemplateId_upLoad = fileTemplatePageItemFirstOne.getSignTemplateId();
                                if (textViewSignTemplate != null) {
                                    textViewSignTemplate.setText(fileTemplatePageItemFirstOne.getSignTemplateName());
                                }
                            }


                            //第一条合同模板默认--------------------------------------------------------------------------
                            for (int indexPosition = 0; indexPosition < runManGroupHeadOrTeamCheckArrayList.size(); indexPosition++) {

                                if (indexPosition == 0) {

                                    EvaluateWadeInfo evaluateWadeInfo_firstOne = new EvaluateWadeInfo();
                                    evaluateWadeInfo_firstOne.setDictCode(runManGroupHeadOrTeamCheckArrayList.get(indexPosition).getSignTemplateId());//合同模板的id 模板ID
                                    evaluateWadeInfo_firstOne.setDictLabel(runManGroupHeadOrTeamCheckArrayList.get(indexPosition).getSignTemplateName());//合同模板的名字
                                    evaluateWadeInfo_firstOne.setChecked(true);

                                    if (mDataResources_evaluateWadeInfo != null) {
                                        mDataResources_evaluateWadeInfo.add(evaluateWadeInfo_firstOne);
                                    }

                                } else {

                                    EvaluateWadeInfo evaluateWadeInfo_other = new EvaluateWadeInfo();
                                    evaluateWadeInfo_other.setDictCode(runManGroupHeadOrTeamCheckArrayList.get(indexPosition).getSignTemplateId());//合同模板的id 模板ID
                                    evaluateWadeInfo_other.setDictLabel(runManGroupHeadOrTeamCheckArrayList.get(indexPosition).getSignTemplateName());//合同模板的名字
                                    evaluateWadeInfo_other.setChecked(false);

                                    if (mDataResources_evaluateWadeInfo != null) {
                                        mDataResources_evaluateWadeInfo.add(evaluateWadeInfo_other);
                                    }

                                }

                            }

                        }

//                        if (runManGroupHeadOrTeamCheckArrayList != null && !runManGroupHeadOrTeamCheckArrayList.isEmpty()) {
//
//                            for (FileTemplatePage fileTemplatePageItem : runManGroupHeadOrTeamCheckArrayList) {
//
//                                EvaluateWadeInfo evaluateWadeInfo = new EvaluateWadeInfo();
//                                evaluateWadeInfo.setDictCode(fileTemplatePageItem.getSignTemplateId());//合同模板的id 模板ID
//                                evaluateWadeInfo.setDictLabel(fileTemplatePageItem.getSignTemplateName());//合同模板的名字
//
//                                //第一条默认设置选中：
//                                if (mDataResources_evaluateWadeInfo != null) {
//                                    mDataResources_evaluateWadeInfo.add(evaluateWadeInfo);
//                                }
//
//                            }
//
//                        }

                        //重新过滤一遍值内容
//                        if (mDataResources_signTemplateName != null && !mDataResources_signTemplateName.isEmpty()) {
//
//                            for (FileTemplatePage fileTemplatePageItem :
//                                    mDataResources_signTemplateName) {
//
//                                EvaluateWadeInfo evaluateWadeInfo = new EvaluateWadeInfo();
//                                evaluateWadeInfo.setDictCode(fileTemplatePageItem.getSignTemplateId());//合同模板的id 模板ID
//                                evaluateWadeInfo.setDictLabel(fileTemplatePageItem.getSignTemplateName());//合同模板的名字
//
//                                if (mDataResources_evaluateWadeInfo != null) {
//                                    mDataResources_evaluateWadeInfo.add(evaluateWadeInfo);
//                                }
//
//                            }
//
//                        }

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {

                    }
                });

    }

    //提交信息
    private void method_gainAddSubmitInfo_upLoad() {

        //合同金额
        HashMap<String, Object> map = new HashMap<>();
        map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());//店铺id

        informationId_upLoad = "";

//        if (extra_signature_fileSignatureAgreement != null) {
//            informationId_upLoad = extra_signature_fileSignatureAgreement.getInformationId();
//        }

        if (extra_signature_fileSignatureManage != null) {
            informationId_upLoad = extra_signature_fileSignatureManage.getInformationId();
        }

        map.put(Parameterkey.informationId, informationId_upLoad);//合同档案的id
        map.put(Parameterkey.managerId, managerId_upLoad);//选中经理人的id
        map.put(Parameterkey.signTemplateId, signTemplateId_upLoad);//合同模板的id
        map.put(Parameterkey.signingDate, appointDate_upLoad);//合同签署日期
        map.put(Parameterkey.vehicleType, vehicleType_upLoad);//合同类型

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_LAUNCHSIGNTASK_URL);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.launchSignTask_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(false);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .launchSignTask(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                        MediaType.parse(ApiService.HEADER_JSON)))
                .compose(SignatureAddSubmitToActivity.this.bindUntilEvent(ActivityEvent.DESTROY))
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<SignatureLaunchSign>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                        CommUtils.checkMaterialDialog(materialDialog);

                        // 做特殊的处理内容
//                        {"data":"","message":"选择的审核人未认证，请通知相关人员进行法大大签章认证！","code":"29999"}

                        if (!TextUtils.isEmpty(serverCode)) {

                            if (TextUtils.equals(serverCode, ConstantSign.RESPONSE_STRING_29999)) {

                                CommUtils.checkDialog(mAlertView);
                                mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, serverMessage, true);
                                mAlertView.show();

//                                CommUtils.checkDialog(mAlertView);
//                                method_show_QRCode_dialog_customer_has_not_signature_tips(serverMessage);

                                // TODO: 2023-11-27 14:11 测试内容，将来删除
//                                method_show_QRCode_dialog_customer_has_not_signature_tips(getResources().getString(R.string.create_reset_signature));

                            } else if (TextUtils.equals(serverCode, ConstantSign.RESPONSE_STRING_27106)) {

                                //客户未能认证，提示引导客户去认证；
                                //public static final String VEHICLE_FASC_NOT_AUTH = "27106";
                                CommUtils.checkDialog(mAlertView);
                                CommUtils.checkMaterialDialog(materialDialog);

                                // TODO: 2023-11-08 10:44 待测试的内容
                                //第一种方式是后台动态给出的提示
//                              method_show_QRCode_dialog_customer_has_not_signature_tips(serverMessage);
                                //第二种方式是我和iOS约定的文字提示
                                method_show_QRCode_dialog_customer_has_not_signature_tips(getResources().getString(R.string.create_reset_signature));

                            } else {

                                ToastUtils.showShort(serverMessage);

                            }

                        }


                    }
                })).doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Throwable {
                        method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_SUBMIT);
                    }
                }).subscribe(new Consumer<SignatureLaunchSign>() {
                    @Override
                    public void accept(SignatureLaunchSign signatureLaunchSign) throws Throwable {

                        CommUtils.checkMaterialDialog(materialDialog);
                        //TipDialog.show(StringUtils.getString(R.string.add_submit_success), WaitDialog.TYPE.SUCCESS);

                        //这里主要是通知刷新档案盒子内的档案详情列表
                        EventSignatureDetail eventSignatureDetail = new EventSignatureDetail();
                        eventSignatureDetail.setMessage(ExtraValue.EVENTBUS_EVENT_TO_REFRESH_SIGNATURE_DETAIL);
                        EventBus.getDefault().post(eventSignatureDetail);

                        //通知主页列表刷新
                        EventSignatureMain eventSignatureMain = new EventSignatureMain();
                        eventSignatureMain.setMessage(ExtraValue.EVENTBUS_EVENT_TO_REFRESH_SIGNATURE_MAIN_LIST);
                        EventBus.getDefault().post(eventSignatureMain);

                        //该页面关闭
                        methodSubmitSuccess(SignatureAddSubmitToActivity.this, new DoSomeThingListener() {
                            @Override
                            public void doSomeThing() {

                                methodBack();

                            }
                        });

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {
                        if (apiException != null) {
                            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "执行到--apiException");
                            ToastUtils.showShort(apiException.getDisplayMessage());
                        }
                    }
                });

    }

    //获取企业联系人：
//    private void gainDatas_sales_consultant() {
//
//        //        {
////                "shopInfoId": 1495,
////                "saleType": 1
////        }
//
//        HashMap<String, Object> map = new HashMap<>();
//        map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());
////        map.put(Parameterkey.vehicleType, 1);
//
//        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
//        addLogUpLoadInfo.setActivity(mActivityInstance);
//        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETCUSTOMERLISTBYSHOP_URL);//请求数字标识
//        addLogUpLoadInfo.setUrlPath(ApiService.getCustomerListByShop_url);//url地址
//        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
//        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
//        addLogUpLoadInfo.setHashMapParameter(map);
//
//        NetworkManager.getInstance().initRetrofitRxJava()
//                .create(ApiService.class)
//                .getCustomerListByShop(RequestBody.create(JSON.toJSONString(map,//
//                                SerializerFeature.PrettyFormat, //
//                                SerializerFeature.WriteMapNullValue), //
//                        MediaType.parse(ApiService.HEADER_JSON)))//
//                .compose(SignatureAddSubmitToActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
//                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<ArrayList<RunManGroupHeadOrTeamCheck>>() {
//                    @Override
//                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
//                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
//
//                        if (!TextUtils.isEmpty(serverMessage)) {
//                            ToastUtils.showShort(serverMessage);
//                        }
//
//                    }
//                })).subscribe(new Consumer<ArrayList<RunManGroupHeadOrTeamCheck>>() {
//                    @Override
//                    public void accept(ArrayList<RunManGroupHeadOrTeamCheck> runManGroupHeadOrTeamCheckArrayList) throws Throwable {
//
//                        //填充列表
//
//                    }
//                }, new ErrorConsumer() {
//
//                    @Override
//                    protected void error(ApiException apiException) {
//
//                    }
//                });
//
//    }

    private MaterialDialog materialDialogCustomView;
    private ClearEditText editViewPhoneEvaluate;

    //检测到客户未完成认证，那么需要提示和引导客户完成认证
    //【发起签约】的弹窗 填写客户信息和合同的类别、客户类别、客户电话和3个按钮内容；
//    private void method_show_QRCode_dialog_customer_has_not_signature() {
//
//        //执行该弹窗的时候要清空弹层以上的所有弹层
//        CommUtils.checkMaterialDialog(materialDialogCustomView);
//
//        //弹窗布局
//        View viewCard = View.inflate(mActivityInstance, R.layout.signature_create_dialog, null);
//
//        if (viewCard != null) {
//
//            //标题 卡券的
//            TextView textViewQrName = (TextView) viewCard.findViewById(R.id.tv_name_signature_popu_title);
//
//            //填充房间号的名称内容
////          textViewQrName.setText(_siteNo);
//
//            //用户手机号内容
//            editViewPhoneEvaluate = (ClearEditText) viewCard.findViewById(R.id.editviewphoneevaluate);
//            //这里一般是携带的有客户的手机号信息，直接填充进去
//            if (!TextUtils.isEmpty(clientPhone_upLoad)) {
//                editViewPhoneEvaluate.setText(clientPhone_upLoad);
//            }
//
//            RadioGroup radioGroupCustomerType = (RadioGroup) viewCard.findViewById(R.id.radiogroupcustomertype);
//            RadioGroup radioGroupVehicleType = (RadioGroup) viewCard.findViewById(R.id.radiogroupvehicletype);
//
//            //合同类型 默认是新车
//            archiveTypeId_upLoad = SignatureVehicleType.VEHICLETYPE_CAR_NEW.getIndex();
//            //默认的类型是 个人类型
//            clientType_upLoad = SignatureClientType.CLIENTTYPE_PERSON.getIndex();
//
//            //个人用户或者企业用户
//            radioGroupCustomerType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
//                @Override
//                public void onCheckedChanged(RadioGroup group, int checkedId) {
//
////                    public enum SignatureClientType {
////                        //客户类型(0:个人;1:企业),默认是个人
////                        CLIENTTYPE_PERSON("0"),
////                        CLIENTTYPE_COMPANY("1");
//
//                    if (checkedId == R.id.radiobuttoncustomertypeperson) {
//
//                        //客户类型(0:个人;1:企业),默认是个人
//                        clientType_upLoad = SignatureClientType.CLIENTTYPE_PERSON.getIndex();
//
//                    } else if (checkedId == R.id.radiobuttoncustomertypecompany) {
//
//                        clientType_upLoad = SignatureClientType.CLIENTTYPE_COMPANY.getIndex();
//
//                    }
//
//
//                }
//            });
//
//            //合同类型 是新车或者是二手车
//            radioGroupVehicleType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
//                @Override
//                public void onCheckedChanged(RadioGroup group, int checkedId) {
//
////                    public enum SignatureVehicleType {
////                        //车辆类型  1新车  2二手车
////                        VEHICLETYPE_CAR_NEW("1"),
////                        VEHICLETYPE_CAR_OLD("2");
//
//                    if (checkedId == R.id.radiobuttonvehicletypecarnew) {
//
//                        archiveTypeId_upLoad = SignatureVehicleType.VEHICLETYPE_CAR_NEW.getIndex();
//
//                    } else if (checkedId == R.id.radiobuttonvehicletypecarold) {
//
//                        archiveTypeId_upLoad = SignatureVehicleType.VEHICLETYPE_CAR_OLD.getIndex();
//                    }
//
//                }
//            });
//
//            //关闭 按钮
//            RoundTextView textViewCardCancel = (RoundTextView) viewCard.findViewById(R.id.textviewsignaturecancelcreate);
//            //认证二维码的按钮
//            RoundTextView textViewToSignatureQRCodeCreate = (RoundTextView) viewCard.findViewById(R.id.textviewtosignatureqrcodecreate);
//            //认证链接
//            RoundTextView textViewToSignatureLinksCreate = (RoundTextView) viewCard.findViewById(R.id.textviewtosignaturelinkscreate);
//
//
//            if (textViewCardCancel != null) {
//                textViewCardCancel.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
//                    @Override
//                    public void onDebouncingClick(View v) {
//
//                        //此时 弹窗是已经被弹出的
//                        if (materialDialogCustomView != null) {
//                            materialDialogCustomView.dismiss();
//                        }
//
//                        //直接关闭该页面整体的,因为不认证是没法儿用的
//                        //methodBack();
//
//                    }
//                });
//            }
//
//
//            if (textViewToSignatureQRCodeCreate != null) {
//
//                textViewToSignatureQRCodeCreate.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
//                    @Override
//                    public void onDebouncingClick(View v) {
//
//                        //打开浏览器的逻辑，是不可行的，放弃；因为交互信息 后台无法给到手机端
//                        //CommUtils.linkJumpDialogSignature(SignatureActivity.this, SignatureActivity.this, _contentResult);
//
//                        //应该是打开内部的webView才可以；可以实现法大大给认证结果给H5，下一步Android和H5交互,这样手机端才知道认证成功；
////                        ViewUitls.method_toWebView_signature(getString(R.string.title_dialog_signature), _contentResult);
//
//                        clientPhone_upLoad = editViewPhoneEvaluate.getText().toString().trim();
//
//                        // TODO: 2023-10-26 16:39 校验为空的手机号为空的
//                        if (TextUtils.isEmpty(clientPhone_upLoad)) {
////                            CommUtils.checkDialog(mAlertView);
////                            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.hint_input_phone), true);
////                            mAlertView.show();
//
////                            PopTip.show(getResources().getString(R.string.hint_input_phone)).iconWarning();
//
//                            new MaterialDialog.Builder(mActivityInstance)
//                                    .title(ConstantSign.ALERT_TITLE)
//                                    .titleGravity(GravityEnum.CENTER)
//                                    .content(getResources().getString(R.string.hint_input_phone))
//                                    .contentGravity(GravityEnum.CENTER)
//                                    .positiveText(getResources().getString(R.string.popubuttonclose))
//                                    //.negativeText("取消")
//                                    .show();
//
////                            TipDialog.show(getResources().getString(R.string.hint_input_phone), WaitDialog.TYPE.ERROR);
//
//                            return;
//                        }
//
//                        //选择客户类型
//                        if (TextUtils.isEmpty(clientType_upLoad)) {
//
////                            CommUtils.checkDialog(mAlertView);
////                            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.dialog_select_clienttype), true);
////                            mAlertView.show();
//
////                            PopTip.show(getResources().getString(R.string.dialog_select_clienttype)).iconWarning();
//
//                            new MaterialDialog.Builder(mActivityInstance)
//                                    .title(ConstantSign.ALERT_TITLE)
//                                    .titleGravity(GravityEnum.CENTER)
//                                    .content(getResources().getString(R.string.dialog_select_clienttype))
//                                    .contentGravity(GravityEnum.CENTER)
//                                    .positiveText(getResources().getString(R.string.popubuttonclose))
//                                    //.negativeText("取消")
//                                    .show();
//
////                            TipDialog.show(getResources().getString(R.string.dialog_select_clienttype), WaitDialog.TYPE.ERROR);
//
//                            return;
//                        }
//
//                        //选择合同类别
//                        if (TextUtils.isEmpty(archiveTypeId_upLoad)) {
//
////                            CommUtils.checkDialog(mAlertView);
////                            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.dialog_select_archivetypeId), true);
////                            mAlertView.show();
//
////                            PopTip.show(getResources().getString(R.string.dialog_select_archivetypeId)).iconWarning();
//
//                            new MaterialDialog.Builder(mActivityInstance)
//                                    .title(ConstantSign.ALERT_TITLE)
//                                    .titleGravity(GravityEnum.CENTER)
//                                    .content(getResources().getString(R.string.dialog_select_archivetypeId))
//                                    .contentGravity(GravityEnum.CENTER)
//                                    .positiveText(getResources().getString(R.string.popubuttonclose))
//                                    //.negativeText("取消")
//                                    .show();
//
////                            TipDialog.show(getResources().getString(R.string.dialog_select_archivetypeId), WaitDialog.TYPE.ERROR);
//
//                            return;
//                        }
//
//                        //信息都填写完毕，提交，关闭该弹窗
//                        if (materialDialogCustomView != null) {
//                            materialDialogCustomView.dismiss();
//                        }
//
//                        //生成客户认证二维码，如果是陌生用户，可能没认证过，有弹窗，如果是老客户，已经认证过，那么就不弹出，直接跳转到添加合同页面
//                        CommUtils.checkMaterialDialog(materialDialog);
//                        gain_create_signature_qrcode_customer();
//
//                    }
//                });
//            }
//
//
//            //认证链接
//            if (textViewToSignatureLinksCreate != null) {
//                textViewToSignatureLinksCreate.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//
//                        //发送认证链接
//                        clientPhone_upLoad = editViewPhoneEvaluate.getText().toString().trim();
//
//                        // TODO: 2023-10-26 16:39 校验为空的手机号为空的
//                        if (TextUtils.isEmpty(clientPhone_upLoad)) {
////                            CommUtils.checkDialog(mAlertView);
////                            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.hint_input_phone), true);
////                            mAlertView.show();
//
////                            PopTip.show(getResources().getString(R.string.hint_input_phone)).iconWarning();
//
//                            new MaterialDialog.Builder(mActivityInstance)
//                                    .title(ConstantSign.ALERT_TITLE)
//                                    .titleGravity(GravityEnum.CENTER)
//                                    .content(getResources().getString(R.string.hint_input_phone))
//                                    .contentGravity(GravityEnum.CENTER)
//                                    .positiveText(getResources().getString(R.string.popubuttonclose))
//                                    //.negativeText("取消")
//                                    .show();
//
////                            TipDialog.show(getResources().getString(R.string.hint_input_phone), WaitDialog.TYPE.ERROR);
//
//                            return;
//                        }
//
//                        //选择客户类型
//                        if (TextUtils.isEmpty(clientType_upLoad)) {
//
////                            CommUtils.checkDialog(mAlertView);
////                            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.dialog_select_clienttype), true);
////                            mAlertView.show();
//
////                            PopTip.show(getResources().getString(R.string.dialog_select_clienttype)).iconWarning();
//
//                            new MaterialDialog.Builder(mActivityInstance)
//                                    .title(ConstantSign.ALERT_TITLE)
//                                    .titleGravity(GravityEnum.CENTER)
//                                    .content(getResources().getString(R.string.dialog_select_clienttype))
//                                    .contentGravity(GravityEnum.CENTER)
//                                    .positiveText(getResources().getString(R.string.popubuttonclose))
//                                    //.negativeText("取消")
//                                    .show();
//
////                            TipDialog.show(getResources().getString(R.string.dialog_select_clienttype), WaitDialog.TYPE.ERROR);
//
//                            return;
//                        }
//
//                        //选择合同类别
//                        if (TextUtils.isEmpty(archiveTypeId_upLoad)) {
////                            CommUtils.checkDialog(mAlertView);
////                            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.dialog_select_archivetypeId), true);
////                            mAlertView.show();
//
////                            PopTip.show(getResources().getString(R.string.dialog_select_archivetypeId)).iconWarning();
//
//                            new MaterialDialog.Builder(mActivityInstance)
//                                    .title(ConstantSign.ALERT_TITLE)
//                                    .titleGravity(GravityEnum.CENTER)
//                                    .content(getResources().getString(R.string.dialog_select_archivetypeId))
//                                    .contentGravity(GravityEnum.CENTER)
//                                    .positiveText(getResources().getString(R.string.popubuttonclose))
//                                    //.negativeText("取消")
//                                    .show();
//
////                            TipDialog.show(getResources().getString(R.string.dialog_select_archivetypeId), WaitDialog.TYPE.ERROR);
//
//                            return;
//                        }
//
//                        //信息都填写完毕，提交，关闭该弹窗
//                        if (materialDialogCustomView != null) {
//                            materialDialogCustomView.dismiss();
//                        }
//
//                        CommUtils.checkMaterialDialog(materialDialog);
//                        gain_send_signature_links_to_customer();
//
//                    }
//                });
//            }
//
//            //激发 弹窗弹出内容
//            materialDialogCustomView = new MaterialDialog.Builder(SignatureAddSubmitToActivity.this)
//                    .customView(viewCard, false)
//                    .contentColor(ColorUtils.getColor(R.color.buttonnomcolor))//
//                    //.positiveText("确定")
//                    .positiveColor(ColorUtils.getColor(R.color.dark))
//                    //.negativeText("取消")
//                    .canceledOnTouchOutside(false)
//                    .show();
//
//        }
//    }

    //检测到客户未完成认证，那么需要提示和引导客户完成认证，客户未完成认证
    private void method_show_QRCode_dialog_customer_has_not_signature_tips(String message_content) {

        //执行该弹窗的时候要清空弹层以上的所有弹层
        CommUtils.checkMaterialDialog(materialDialogCustomView);

        //引导客户认证的弹窗：
        View viewCard = View.inflate(mActivityInstance, R.layout.signature_create_dialog_tips, null);

        //客户未完成认证的弹窗文字提示
        TextView textViewQRMessage = (TextView) viewCard.findViewById(R.id.textviewqrmessage);
        textViewQRMessage.setText(message_content);

        //生成客户认证二维码
        RoundTextView textViewToSignatureQRCodeCreateTips = (RoundTextView) viewCard.findViewById(R.id.textviewtosignatureqrcodecreatetips);
        //发送认证链接到给客户完成
//        RoundTextView textViewToSignatureLinksCreateTips = (RoundTextView) viewCard.findViewById(R.id.textviewtosignaturelinkscreatetips);
        //关闭按钮
        RoundTextView textViewSignatureCancelCreateTips = (RoundTextView) viewCard.findViewById(R.id.textviewsignaturecancelcreatetips);

        //clicks
        //生成客户认证二维码
        textViewToSignatureQRCodeCreateTips.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                //弹出发起客户填写认证的信息，还是旧的逻辑.
                //这里是直接跳转到 填写客户信息的认证页面
                //method_show_QRCode_dialog_customer_has_not_signature();
                Bundle extra_bundle = new Bundle();
                //携带必要信息
                extra_bundle.putInt(ExtraKey.EXTRA_JUMPFROM_WHERE, ExtraValue.VALUE_JUMP_FORM_SIGNATRUE_ADDSUBMIT_TO_ACTIVITY);
                //携带实体信息
                extra_bundle.putParcelable(ExtraKey.EXTRA_SIGNATURE_FILESIGNATUREMANAGE, extra_signature_fileSignatureManage);
                //这是到选择合同模板页面，携带部分信息，最低程度携带手机信息
                ActivityUtils.startActivity(extra_bundle, InputCustomerActivity.class);

                //该页面要关闭，重新打开档案盒子，再点进来
                methodBack();

            }
        });

        //关闭
        textViewSignatureCancelCreateTips.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                //此时 弹窗是已经被弹出的
                if (materialDialogCustomView != null) {
                    materialDialogCustomView.dismiss();
                }

            }
        });

        //激发 弹窗弹出内容
        materialDialogCustomView = new MaterialDialog.Builder(SignatureAddSubmitToActivity.this)
                .customView(viewCard, false)
                .contentColor(ColorUtils.getColor(R.color.buttonnomcolor))//
                //.positiveText("确定")
                .positiveColor(ColorUtils.getColor(R.color.dark))
                //.negativeText("取消")
                .canceledOnTouchOutside(false)
                .show();


    }

    //生成客户认证二维码，
    private void gain_create_signature_qrcode_customer() {

        if (NetworkUtils.isConnected()) {

            HashMap<String, Object> map = new HashMap<>();
            map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());//,
            map.put(Parameterkey.clientPhone, clientPhone_upLoad);//,客户手机号

            map.put(Parameterkey.clientType, clientType_upLoad);//,clientType 客户类型(0:个人;1:企业),默认是个人
            map.put(Parameterkey.archiveTypeId, archiveTypeId_upLoad);//档案的类型，是新车 还是二手车

            AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
            addLogUpLoadInfo.setActivity(mActivityInstance);
            addLogUpLoadInfo.setWhat(ConstantApi.WHAT_CHECKOPENFASC_URL);//请求数字标识
            addLogUpLoadInfo.setUrlPath(ApiService.checkOpenFasc_url);//url地址
            addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
            addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
            addLogUpLoadInfo.setHashMapParameter(map);

            NetworkManager.getInstance().initRetrofitRxJava()
                    .create(ApiService.class)
                    .getFascAuthQr(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                            MediaType.parse(ApiService.HEADER_JSON)))
                    .compose(SignatureAddSubmitToActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                    .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<SignatureWebInformationBean>() {
                        @Override
                        public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                            super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
                            //{"data":"","message":"无更多数据","code":"29999"}
                            CommUtils.checkMaterialDialog(materialDialog);

                            //这里要不要给提示？无更多数据
                            if (!TextUtils.isEmpty(serverMessage)) {
                                ToastUtils.showShort(serverMessage);
                            }

                        }
                    })).doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(Disposable disposable) throws Throwable {
                            method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_SUBMIT);
                        }
                    }).subscribe(new Consumer<SignatureWebInformationBean>() {
                        @Override
                        public void accept(SignatureWebInformationBean signatureWebInformationBean) throws Throwable {

//                            {
//                                "code": "20000",
//                                    "data": {
//                                   "authUrl": "https://80000333.uat-e.fadada.com/authorizeui/person/login?authSerial=2dedef36d279452d82ed3cadb1d2dd7f", //法大大认证连接
//                                        "qrUrl": "http://222.222.17.184:8990/resource/15144218047-1499.jpg", //认证二维码图片地址
//                                        "informationId": 2 //合同档案ID
//                            },
//                                "message": "success"
//                            }


                            //真实接口
//                            {
//                                "code":"20000",
//                                        "data":{
//                                        "authUrl":"https://80000333.uat-e.fadada.com/authorizeui/person/login?authSerial=59e8e4a8223640659f64a056dbf3334a",
//                                        "qrUrl":"http://222.222.17.184:8990/resource/17531108969-1495认证二维码.jpg",
//                                        "informationId":3
//                            },
//                                "message":"success"
//                            }

                            CommUtils.checkMaterialDialog(materialDialog);

                            // TODO: 2023-10-26 18:25 存入本地 做接口携带用到；
                            //存入 informationId 的值内容；
                            String informationId = signatureWebInformationBean.getInformationId();
                            mSession.setInformationId(informationId);

                            //MMKV.defaultMMKV().encode(ConstantSign.P_INFORMATIONID, informationId);

                            //链接的地址信息
                            String authUrl = signatureWebInformationBean.getAuthUrl();

                            // TODO: 2023-10-26 18:24  获取到二维码链接  怎么用呢？
                            //二维码的地址信息  ?怎么用呢？
                            String qrUrl = signatureWebInformationBean.getQrUrl();

                            //获取这个客户是否已经开通过法大大
                            boolean fascAuth = signatureWebInformationBean.getFascAuth();

//                            if (!TextUtils.isEmpty(informationId)) {
//                                //怎么用？
//                            }

                            //如果用户已经开通过法大大，那么，提示，并跳转到档案盒子，添加
                            if (fascAuth) {

//                                PopTip.show(getResources().getString(R.string.send_links_to_hasqrcode)).iconSuccess();

                                //客户已经认证过法大大认证，请新建合同；
//                                method_show_QRCode_dialog_customer_has_signature(signatureWebInformationBean);


                            } else {

                                //如果没有开通过法大大，那么
                                if (!TextUtils.isEmpty(qrUrl)) {

                                    PopTip.show(getResources().getString(R.string.send_links_to_qrcode)).iconSuccess();

                                    method_show_QRCode_dialog(qrUrl);

                                }
                            }

                        }
                    }, new ErrorConsumer() {

                        @Override
                        protected void error(ApiException apiException) {

                            CommUtils.checkMaterialDialog(materialDialog);

                            //页面报错；给提示
                            if (apiException != null) {
                                ToastUtils.showShort(apiException.getDisplayMessage());
                            }

                        }
                    });

        } else {

            ToastUtils.showShort(StringUtils.getString(R.string.http_exception_network));

        }

    }

    //发送认证链接到客户手机，给客户发送短信；
    private void gain_send_signature_links_to_customer() {

        clientPhone_upLoad = editViewPhoneEvaluate.getText().toString().trim();

        if (NetworkUtils.isConnected()) {

            HashMap<String, Object> map = new HashMap<>();
            map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());//,
            map.put(Parameterkey.clientPhone, clientPhone_upLoad);//,客户手机号
            map.put(Parameterkey.clientType, clientType_upLoad);//,clientType 客户类型(0:个人;1:企业),默认是个人
            map.put(Parameterkey.archiveTypeId, archiveTypeId_upLoad);//档案的类型，是新车 还是二手车

            AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
            addLogUpLoadInfo.setActivity(mActivityInstance);
            addLogUpLoadInfo.setWhat(ConstantApi.WHAT_SENDOPENFASCAUTHURL_URL);//请求数字标识
            addLogUpLoadInfo.setUrlPath(ApiService.sendOpenFascAuthUrl_url);//url地址
            addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
            addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
            addLogUpLoadInfo.setHashMapParameter(map);

            NetworkManager.getInstance().initRetrofitRxJava()
                    .create(ApiService.class)
                    .sendOpenFascAuthUrl(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                            MediaType.parse(ApiService.HEADER_JSON)))
                    .compose(SignatureAddSubmitToActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                    .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<SignatureWebInformationBean>() {
                        @Override
                        public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                            super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                            //{"data":"","message":"无更多数据","code":"29999"}
                            CommUtils.checkMaterialDialog(materialDialog);

                            //这里要不要给提示？无更多数据
                            if (!TextUtils.isEmpty(serverMessage)) {
                                ToastUtils.showShort(serverMessage);
                            }

                        }
                    })).doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(Disposable disposable) throws Throwable {
                            //
                            method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_SUBMIT);
                        }
                    }).subscribe(new Consumer<SignatureWebInformationBean>() {
                        @Override
                        public void accept(SignatureWebInformationBean signatureWebInformationBean) throws Throwable {


//                            {
//                                "code":"20000",
//                                    "data":{
//                                     "authUrl":"https://80000333.uat-e.fadada.com/authorizeui/person/login?authSerial=59e8e4a8223640659f64a056dbf3334a",
//                                        "informationId":3
//                            },
//                                "message":"success"
//                            }

                            CommUtils.checkMaterialDialog(materialDialog);

                            // TODO: 2023-10-26 18:25 存入本地 做接口携带用到；
                            //存入 informationId 的值内容；
                            String informationId = signatureWebInformationBean.getInformationId();
                            mSession.setInformationId(informationId);

                            //MMKV.defaultMMKV().encode(ConstantSign.P_INFORMATIONID, informationId);
                            String authUrl = signatureWebInformationBean.getAuthUrl();

                            if (!TextUtils.isEmpty(authUrl)) {
                                //提示发送成功或者失败：
                                PopTip.show(getResources().getString(R.string.send_links_to_customer)).iconSuccess();
                            }


                        }
                    }, new ErrorConsumer() {

                        @Override
                        protected void error(ApiException apiException) {

                            CommUtils.checkMaterialDialog(materialDialog);

                            //页面报错；给提示
                            if (apiException != null) {
                                ToastUtils.showShort(apiException.getDisplayMessage());
                            }

                        }
                    });

        } else {

            ToastUtils.showShort(StringUtils.getString(R.string.http_exception_network));

        }


    }

    //生成客户认证的二维码的那个二维码的弹窗，一个关闭，一个打开二维码图片的功能；
    private void method_show_QRCode_dialog(String _imageUrl) {

        //执行该弹窗的时候要清空弹层以上的所有弹层
        CommUtils.checkMaterialDialog(materialDialogCustomView);

        View viewCard = View.inflate(mActivityInstance, R.layout.qrcodemiddlepopu, null);

        if (viewCard != null) {

            //暂时没有标题？
            TextView textViewQrName = (TextView) viewCard.findViewById(R.id.textviewqrname);
            //弹窗的标题内容
            TextView textNamePopu = (TextView) viewCard.findViewById(R.id.tv_namepopu);
            textNamePopu.setText("认证二维码");

            //填充房间号的名称内容
//          textViewQrName.setText(_siteNo);

            //图片的内容  imageviewpaintbookingqrcode
            ImageView imageViewQRCode = (ImageView) viewCard.findViewById(R.id.imageviewpaintbookingqrcode);
            //关闭 按钮
            RoundTextView textViewCardCancel = (RoundTextView) viewCard.findViewById(R.id.textviewqrcodecancel);
            //保存为图片的按钮
            RoundTextView textViewCardSure = (RoundTextView) viewCard.findViewById(R.id.textviewqrcodesave);
            //友盟分享的内容
//           RoundTextView textViewQrcodeShare = (RoundTextView) viewCard.findViewById(R.id.textViewQrcodeShare);
//
            String imagePathFolder = PathUtils.getExternalAppFilesPath() + File.separator + ConstantSign.DOWNAPP;
            FileUtils.createOrExistsDir(imagePathFolder);
            //FileUtils.createOrExistsFile(imagePathFolder);
            String imagePathFile = PathUtils.getExternalAppFilesPath() + File.separator + ConstantSign.DOWNAPP + File.separator + ConstantSign.IMG + TimeUtils.getNowString() + ConstantSign.IMG_POSTFIX;
            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "图片的本地路径是-->" + imagePathFile);
            //itchen-->图片的本地路径是-->/storage/emulated/0/Android/data/com.ygxsk.carhome/files/downapp/img2023-10-26 19:50:26.jpg
//            String testUrl = "http://222.222.17.184:8990/resource/image/houseTypeImg/20230818/2023081809380999347987.png";
            method_inside_download(_imageUrl, imagePathFile);

            //将图片下载到指定目录:
//            boolean resultValue = DemoImage.base64ToImage(_imageUrlBase64, imagePath);
//            //boolean resultValue = DemoImage.base64ToImage(_imageUrlBase64, PathUtils.getExternalAppFilesPath() + File.separator + ConstantSign.IMG + TimeUtils.getNowString() + ConstantSign.IMG_POSTFIX);

            Glide.with(SignatureAddSubmitToActivity.this)
                    .load(_imageUrl)
                    .placeholder(R.drawable.icon_errorfang)//
                    .error(R.drawable.icon_errorfang)//
                    .fitCenter()
                    .diskCacheStrategy(DiskCacheStrategy.NONE)//动态获取新值不缓存
//                        .override(120, 60)
                    .into(imageViewQRCode);

//                点击查看大图
            if (imageViewQRCode != null) {
                imageViewQRCode.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
                    @Override
                    public void onDebouncingClick(View v) {
                        //验证码的查看大图
                        new XPopup.Builder(SignatureAddSubmitToActivity.this)
                                .asImageViewer(imageViewQRCode, //
                                        _imageUrl,//直接展示动态链接图，或者静态图也可以
                                        new SmartGlideImageLoader())//
                                .show();
                    }
                });
            }

            //客户二维码关闭的话，也要刷新列表
            if (textViewCardCancel != null) {
                textViewCardCancel.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
                    @Override
                    public void onDebouncingClick(View v) {

                        //此时 弹窗是已经被弹出的
                        if (materialDialogCustomView != null) {
                            materialDialogCustomView.dismiss();
                        }

                        //客户认证完毕，应该是新建了一个档案盒子；要刷新
                        EventSignatureMain eventSignatureMainList = new EventSignatureMain();
                        eventSignatureMainList.setMessage(ExtraValue.EVENTBUS_EVENT_TO_REFRESH_SIGNATURE_MAIN_LIST);
                        EventBus.getDefault().post(eventSignatureMainList);

                    }
                });
            }

            //点击打开图片的时候就关闭弹窗：
            if (textViewCardSure != null) {

                textViewCardSure.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
                    @Override
                    public void onDebouncingClick(View v) {


                        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {

                            //获取权限
                            if (!AndPermission.hasPermissions(mActivityInstance, Permission.WRITE_EXTERNAL_STORAGE)
                                    || !AndPermission.hasPermissions(mActivityInstance, Permission.READ_EXTERNAL_STORAGE)) {

                                CommUtils.checkMaterialDialog(materialDialog);

                                materialDialog = CommUtils.authorityRequest(mActivityInstance, ConstantSign.MATERIALDIALOG_AUTHORITY_CONTENT_STORAGE, new AuthorityCallbackListener() {
                                    @Override
                                    public void doSomeThing() {

                                        CommUtils.checkMaterialDialog(materialDialog);

                                        //添加访问权限内容
                                        AndPermission.with(SignatureAddSubmitToActivity.this)
                                                .runtime()//
                                                .permission(Permission.READ_EXTERNAL_STORAGE, //
                                                        Permission.WRITE_EXTERNAL_STORAGE)//
                                                .rationale(new RuntimeRationale())//
                                                .onGranted(new com.yanzhenjie.permission.Action<List<String>>() {
                                                    @Override
                                                    public void onAction(List<String> permissions) {

                                                        if (materialDialogCustomView != null) {
                                                            materialDialogCustomView.dismiss();
                                                        }

                                                        methodOpenImage(imagePathFolder);

                                                    }
                                                }).onDenied(new com.yanzhenjie.permission.Action<List<String>>() {
                                                    @Override
                                                    public void onAction(List<String> permissions) {

                                                        ToastUtils.showShort(ConstantSign.NEEDPERMISS_PHONE);

                                                        PermissionSetting permissionSetting = new PermissionSetting(mActivityInstance);

                                                        if (AndPermission.hasAlwaysDeniedPermission(SignatureAddSubmitToActivity.this, permissions)) {
                                                            permissionSetting.showSetting(ConstantApi.PERMISSION_NORMAL, SignatureAddSubmitToActivity.this, permissions);
                                                        }

                                                    }
                                                }).start();

                                    }
                                });

                            } else {

                                if (materialDialogCustomView != null) {
                                    materialDialogCustomView.dismiss();
                                }

//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "正常的权限已经打开，可以执行拍照操作");
                                methodOpenImage(imagePathFolder);

                            }

                        } else {

                            if (!XXPermissions.isGranted(mActivityInstance, com.hjq.permissions.Permission.READ_MEDIA_IMAGES)) {//

                                CommUtils.checkMaterialDialog(materialDialog);

                                materialDialog = CommUtils.authorityRequest(mActivityInstance, ConstantSign.MATERIALDIALOG_AUTHORITY_CONTENT_ALBUM, new AuthorityCallbackListener() {
                                    @Override
                                    public void doSomeThing() {

                                        CommUtils.checkMaterialDialog(materialDialog);

                                        XXPermissions.with(SignatureAddSubmitToActivity.this)
                                                // 适配分区存储应该这样写
                                                //.permission(Permission.Group.STORAGE)
                                                // 不适配分区存储应该这样写
                                                .permission(com.hjq.permissions.Permission.READ_MEDIA_IMAGES)//
//                                                    .permission(com.hjq.permissions.Permission.READ_MEDIA_IMAGES)//
//                                                  .permission(com.hjq.permissions.Permission.READ_MEDIA_VIDEO)//
//                                                   .permission(com.hjq.permissions.Permission.READ_MEDIA_AUDIO)//
                                                //).permission(com.hjq.permissions.Permission.MANAGE_EXTERNAL_STORAGE
//                                                        .interceptor(new PermissionInterceptor())
                                                .request(new OnPermissionCallback() {

                                                    @Override
                                                    public void onGranted(@NonNull List<String> permissions, boolean allGranted) {

                                                        if (!allGranted) {
                                                            // TODO: 2024/1/23 18:50 权限这里要不要给提示？权限没通过

                                                            return;
                                                        }

                                                        Toaster.show(String.format(getString(R.string.demo_obtain_permission_success_hint),
                                                                PermissionNameConvert.getPermissionString(SignatureAddSubmitToActivity.this, permissions)));

                                                        if (materialDialogCustomView != null) {
                                                            materialDialogCustomView.dismiss();
                                                        }

                                                        methodOpenImage(imagePathFolder);

                                                    }
                                                });
                                    }
                                });

                            } else {

                                if (materialDialogCustomView != null) {
                                    materialDialogCustomView.dismiss();
                                }

                                methodOpenImage(imagePathFolder);

                            }
                        }
                    }
                });
            }

            //激发 弹窗弹出内容
            materialDialogCustomView = new MaterialDialog.Builder(SignatureAddSubmitToActivity.this)
                    .customView(viewCard, false)
                    .contentColor(ColorUtils.getColor(R.color.buttonnomcolor))//
                    //.positiveText("确定")
                    .positiveColor(ColorUtils.getColor(R.color.dark))
                    //.negativeText("取消")
                    .canceledOnTouchOutside(false)
                    .show();

            //materialDialog.getTitleView().setTextSize(16f);

        }

    }

    //直接打开文件的路径，打开文件,2023-10-27 09:04:42 我指定的是打开文件夹：
    private void methodOpenImage(String _imagePathFolder) {

        //直接打开到文件夹
        final ZFileConfiguration configuration = new ZFileConfiguration.Build()
                .filePath(PathUtils.getExternalAppFilesPath() + File.separator + ConstantSign.DOWNAPP + File.separator)
                .boxStyle(ZFileConfiguration.STYLE2)
//                .sortordBy(ZFileConfiguration.BY_DEFAULT)
                .sortordBy(ZFileConfiguration.BY_DATE)//按照日期的顺序排序
                .sortord(ZFileConfiguration.DESC)//倒序排列
                .maxLength(1)
                .maxLengthStr("最多选1个！")
                .useSAF(false)
                .build();

        ZFileContent.getZFileHelp()
                .setConfiguration(configuration)
                .start(SignatureAddSubmitToActivity.this);

    }

    //在这里处理任务执行中的状态，如进度进度条的刷新
    @Download.onTaskRunning
    protected void running(DownloadTask task) {

//        if(task.getKey().eques(task.getKey())){
//        ....
//            可以通过url判断是否是指定任务的回调
//        }
        int p = task.getPercent();  //任务进度百分比
//        String speed = task.getConvertSpeed();  //转换单位后的下载速度，单位转换需要在配置文件中打开
//        String speed1 = String.valueOf(task.getSpeed()); //原始byte长度速度
//        LogUtils.d(ConstantSign.LOGCAT_NOMAL+"下载进度是-->"+speed);
        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "下载进度是-->" + p);

//        if (callbackResult != null) {
//            callbackResult.OnBackResult(p);
//        }

    }

    @Download.onTaskComplete
    void taskComplete(DownloadTask task) {
        //在这里处理任务完成的状态
        //下载完毕
        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "下载完毕；");
        //String filePath = PathUtils.getExternalAppCachePath() + File.separator + (_downLoadUrlCurrent.substring(_downLoadUrlCurrent.lastIndexOf("/") + 1));
        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "下载完毕后的地址-->" + task.getFilePath());
        //itchen-->下载完毕后的地址-->/storage/emulated/0/Android/data/com.ygxsk.carhome/files/downapp/img2023-10-27 08:54:36.jpg

        //直接启用安装
//        if (!TextUtils.isEmpty(task.getFilePath())) {
//            if (CommUtils.getUninatllApkInfo(LoginCarActivity.this, task.getFilePath())) {
//                ///data/user/0/com.ygxsk.integrated/cache/2970b8290303428eb08f0805be10db3d.apk
//                AppUtils.installApp(task.getFilePath());
//            }
//        }

    }

    @Download.onTaskCancel
    void taskCancel(DownloadTask task) {

        //LogUtils.d(ConstantSign.LOGCAT_NOMAL+"---->下载取消---");

        //mAdapter.updateState(task.getEntity());
        //判断这个任务在运行的状态中，那么，就直接停止它；
//        if (Aria.download(SettingActivity.this).load(taskDownLoadApkId).isRunning()){
//            Aria.download(SettingActivity.this).load(taskDownLoadApkId).stop();
//        }

        //直接关闭 下载弹窗；
        //立即关闭弹窗的
//        CommUtils.checkMaterialDialog(materialDialogHasUpdateData);
//        CommUtils.checkMaterialDialog(materialDialogDownLoadProgress);

        ToastUtils.showLong(R.string.downlaodappcancel);

    }

    /**
     * @param e 异常信息
     */
    @Download.onTaskFail
    void taskFail(DownloadTask task, Exception e) {

        //立即关闭弹窗的
//        CommUtils.checkMaterialDialog(materialDialogHasUpdateData);
//        CommUtils.checkMaterialDialog(materialDialogDownLoadProgress);

        //ALog.d(TAG, ALog.getExceptionString(e));
        //下载任务失败
        //下载失败
        if (!TextUtils.isEmpty(ALog.getExceptionString(e))) {

            ToastUtils.showShort(ALog.getExceptionString(e));
//            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "---->下载报错--->" + ALog.getExceptionString(e));
            //提示下载失败：
            ToastUtils.showShort(ALog.getExceptionString(e));
        }
    }

    //直接执行下载
    private void method_inside_download(String _downLoadUrlCurrent, String _imagePathLocal) {

        //使用第三方下载
        taskDownLoadApkId = Aria.download(this)
                .load(_downLoadUrlCurrent)
                .setFilePath(_imagePathLocal) //设置文件保存的完整路径,我设置的全路径
                .create();   //启动下载

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        if (basePopupViewAgreenmentTime != null) {
            basePopupViewAgreenmentTime.onDestroy();
            basePopupViewAgreenmentTime = null;
        }

        if (extra_signature_fileSignatureManage != null) {
            extra_signature_fileSignatureManage = null;
        }

        if (mDataResources_evaluateWadeInfo != null && !mDataResources_evaluateWadeInfo.isEmpty()) {
            mDataResources_evaluateWadeInfo.clear();
            mDataResources_evaluateWadeInfo = null;
        }

        CommUtils.checkBasePopupView(basePopupView_signTemplateName);

    }

    @Override
    protected void methodBack() {

        methodBackFinish();

    }

    @Override
    public void processExtraData() {

        Bundle extras_bundle = this.getIntent().getExtras();

        if (extras_bundle != null) {

            //标志 是 添加 潜客 或者 是修改潜客 信息
            flag_jumpfrom_where = extras_bundle.getInt(ExtraKey.EXTRA_JUMPFROM_WHERE);

//            extra_signature_fileSignatureAgreement = extras_bundle.getParcelable(ExtraKey.EXTRA_SIGNATURE_FILESIGNATURE_AGREEMENT);
            extra_signature_fileSignatureManage = extras_bundle.getParcelable(ExtraKey.EXTRA_SIGNATURE_FILESIGNATUREMANAGE);

            //如果是【编辑】过来的，将携带的数据赋值，并且填充textview或者editview
//            if (extra_signature_fileSignatureAgreement != null) {
//
//                vehicleType_upLoad = extra_signature_fileSignatureManage.getVehicleType();
//                informationId_upLoad = extra_signature_fileSignatureAgreement.getInformationId();
//
//
//                LogUtils.json(ConstantSign.LOGCAT_NOMAL + "这是详情携带的数据--extra_signature_fileSignatureAgreement", extra_signature_fileSignatureAgreement);
//                LogUtils.json(ConstantSign.LOGCAT_NOMAL + "这是详情携带的数据--informationId_upLoad", informationId_upLoad);
//
//            }

            if (extra_signature_fileSignatureManage != null) {

                LogUtils.json(ConstantSign.LOGCAT_NOMAL + "这是详情携带的数据--extra_signature_fileSignatureManage", extra_signature_fileSignatureManage);

                informationId_upLoad = extra_signature_fileSignatureManage.getInformationId();

                //获取客户信息用到的内容
                vehicleType_upLoad = extra_signature_fileSignatureManage.getVehicleType();
//                clientType_upLoad = extra_signature_fileSignatureManage.getc
                clientPhone_upLoad = extra_signature_fileSignatureManage.getClientPhone();

//                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "这是详情携带的数据--extra_signature_fileSignatureManage", informationId_upLoad);

            }

        }

    }
}